<template>
	<view class="container">
		<uv-navbar title="连接WIFI" bg-color="none" @leftClick="leftClick"></uv-navbar>
		<view class="wx-box">
			<view class="name">WiFi名称</view>
			<view class="content">{{name}}</view>
			<view class="password">Wi-Fi密码</view>
			<view class="content">{{password}}</view>
		</view>
		<view class="button-fb" @click="onSubmit">立即连接</view>
		<uv-popup ref="popup" bgColor="none">
			<view class="wifi-pop-1">
				<image class="top-image"
					src="http://jy-nfc.oss-cn-hangzhou.aliyuncs.com/2024/12/26/feee300c158f4e3a9f9210da1ab8a93b.png"
					mode="aspectFill"></image>
				<view class="wifi-pop">
					<view style="margin-bottom: 60rpx;">连接wifi</view>
					<view style="margin-bottom: 32rpx;">WIFI名称：{{name}}</view>
					<view style="margin-bottom: 60rpx;">WIFI密码：{{password}}</view>
					<view class="connect" @click="onConnect">立即连接</view>
				</view>
			</view>
		</uv-popup>
	</view>
</template>

<script>
	const app = getApp();
	import {
		getWxSchemeInfo
	} from '@/common/api.js'
	export default {
		data() {
			return {
				name: '',
				password: '',
			};
		},
		onShow() {
			this.name = this.$store.state.user.merchantInfo.storeWifiName
			this.password = this.$store.state.user.merchantInfo.storeWifiPassword
		},
		methods: {
			leftClick() {
				app.navigateBack()
			},

			onSubmit() {
				this.$refs.popup.open();
			},
			onConnect() {
				getWxSchemeInfo({
					"path": "pages/home/home",
					"query": `name=${this.name}&password=${this.password}`,
					"env_version": "trial"
				}).then(res => {
					console.log(res);
					if (res.data.openlink) {
						window.location.href = res.data.openlink
					}
				}).catch(err => {
					console.log(err);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		overflow: hidden;
		min-height: 100vh;
		width: 100vw;
		padding: 40rpx;
		padding-top: 226rpx;
		// padding-bottom: calc(96rpx + 32rpx + 22rpx);
		box-sizing: border-box;
		background: radial-gradient(128% 128% at 95% 0%, #D7CEFF 0%, #BBE1FF 62%, #FFFFFF 95%);

		.button-fb {
			width: 480rpx;
			height: 96rpx;
			background: linear-gradient(180deg, #886AE6 0%, #4635FF 99%);
			border-radius: 48rpx;
			font-weight: 400;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 96rpx;
			text-align: center;
			margin: 0 auto;
			margin-top: 60rpx;
		}

		.wx-box {
			background: rgba(255, 255, 255, 0.3);
			border-radius: 32rpx;
			border: 2rpx solid #FFFFFF;
			box-sizing: border-box;
			padding: 44rpx 40rpx;
			box-sizing: border-box;
			font-weight: 400;
			font-size: 32rpx;
			color: #000000;
			line-height: 48rpx;

			.name {
				&::before {
					font-family: "dy-iconfont";
					content: "\e7e0";
					font-size: 40rpx;
					padding-right: 22rpx;
					box-sizing: border-box;
				}
			}

			.password {
				margin-top: 44rpx;

				&::before {
					font-family: "dy-iconfont";
					content: "\e636";
					font-size: 40rpx;
					font-weight: 500;
					padding-right: 22rpx;
					box-sizing: border-box;
				}
			}

			.content {
				margin-top: 20rpx;
				height: 80rpx;
				background: rgba(255, 255, 255, 0.3);
				border-radius: 16rpx;
				padding: 18rpx 20rpx;
				box-sizing: border-box;
				font-weight: 400;
				font-size: 30rpx;
				color: #000000;
			}
		}

		.wifi-pop-1 {
			position: relative;
			padding-top: 150rpx;

			.top-image {
				position: absolute;
				top: 0;
				left: 50%;
				transform: translateX(-50%);
				width: 282rpx;
				height: 286rpx;
			}
		}

		.wifi-pop {
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 614rpx;
			height: 568rpx;
			background: #FFFFFF;
			padding: 168rpx 0 80rpx 0;
			box-sizing: border-box;
			border-radius: 80rpx;


			.connect {
				width: 392rpx;
				height: 80rpx;
				background: linear-gradient(180deg, #886AE6 0%, #4635FF 99%);
				border-radius: 80rpx;
				font-weight: 400;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 80rpx;
				text-align: center;
			}
		}
	}
</style>